/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) Huawei Technologies Co., Ltd. 2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Dec 28 14:11:04 2023
 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM sdma

#if !defined(_TRACE_SDMA_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SDMA_H

#include <linux/tracepoint.h>

TRACE_EVENT(sdma_memcpy_start,
	TP_PROTO(unsigned long dst, unsigned long src, unsigned long size),

	TP_ARGS(dst, src, size),

	TP_STRUCT__entry(
		__field(unsigned long, dst)
		__field(unsigned long, src)
		__field(unsigned long, size)
	),

	TP_fast_assign(
		__entry->dst = dst;
		__entry->src = src;
		__entry->size = size;
	),

	TP_printk("dst=%#lx src=%#lx size=%#lx", __entry->dst, __entry->src, __entry->size)
);

TRACE_EVENT(sdma_memcpy_end,
	TP_PROTO(unsigned long dst, unsigned long src, unsigned long size, int ret),

	TP_ARGS(dst, src, size, ret),

	TP_STRUCT__entry(
		__field(unsigned long, dst)
		__field(unsigned long, src)
		__field(unsigned long, size)
		__field(int, ret)
	),

	TP_fast_assign(
		__entry->dst = dst;
		__entry->src = src;
		__entry->size = size;
		__entry->ret = ret;
	),

	TP_printk("dst=%#lx src=%#lx size=%#lx ret=%d",
		__entry->dst, __entry->src, __entry->size, __entry->ret)
);

TRACE_EVENT(sdma_kernel_memcpy_start,
	TP_PROTO(unsigned long dst, unsigned long src, unsigned long size),

	TP_ARGS(dst, src, size),

	TP_STRUCT__entry(
		__field(unsigned long, dst)
		__field(unsigned long, src)
		__field(unsigned long, size)
	),

	TP_fast_assign(
		__entry->dst = dst;
		__entry->src = src;
		__entry->size = size;
	),

	TP_printk("dst=%#lx src=%#lx size=%#lx", __entry->dst, __entry->src, __entry->size)
);

TRACE_EVENT(sdma_kernel_memcpy_end,
	TP_PROTO(unsigned long dst, unsigned long src, unsigned long size, int ret),

	TP_ARGS(dst, src, size, ret),

	TP_STRUCT__entry(
		__field(unsigned long, dst)
		__field(unsigned long, src)
		__field(unsigned long, size)
		__field(int, ret)
	),

	TP_fast_assign(
		__entry->dst = dst;
		__entry->src = src;
		__entry->size = size;
		__entry->ret = ret;
	),

	TP_printk("dst=%#lx src=%#lx size=%#lx ret=%d",
		__entry->dst, __entry->src, __entry->size, __entry->ret)
);

TRACE_EVENT(sdma_kernel_memset_start,
	TP_PROTO(unsigned long addr, unsigned long size, int pasid, int sid, unsigned pattern),

	TP_ARGS(addr, size, pasid, sid, pattern),

	TP_STRUCT__entry(
		__field(unsigned long, addr)
		__field(unsigned long, size)
		__field(int, pasid)
		__field(int, sid)
		__field(unsigned, pattern)
	),

	TP_fast_assign(
		__entry->addr = addr;
		__entry->size = size;
		__entry->pasid = pasid;
		__entry->sid = sid;
		__entry->pattern = pattern;
	),

	TP_printk("addr=%#lx size=%#lx pasid=%d sid=%d pattern=%#x",
		__entry->addr, __entry->size, __entry->pasid, __entry->sid, __entry->pattern)
);

TRACE_EVENT(sdma_kernel_memset_end,
	TP_PROTO(unsigned long addr, unsigned long size, int pasid, int sid, unsigned pattern, int ret),

	TP_ARGS(addr, size, pasid, sid, pattern, ret),

	TP_STRUCT__entry(
		__field(unsigned long, addr)
		__field(unsigned long, size)
		__field(int, pasid)
		__field(int, sid)
		__field(unsigned, pattern)
		__field(int, ret)
	),

	TP_fast_assign(
		__entry->addr = addr;
		__entry->size = size;
		__entry->pasid = pasid;
		__entry->sid = sid;
		__entry->pattern = pattern;
		__entry->ret = ret;
	),

	TP_printk("addr=%#lx size=%#lx pasid=%d sid=%d pattern=%#x ret=%d",
		__entry->addr, __entry->size, __entry->pasid, __entry->sid, __entry->pattern, __entry->ret)
);

TRACE_EVENT(sdma_copy_batch_start,
	TP_PROTO(unsigned long count),

	TP_ARGS(count),

	TP_STRUCT__entry(
		__field(unsigned long, count)
	),

	TP_fast_assign(
		__entry->count = count;
	),

	TP_printk("count=%#lx", __entry->count)
);

TRACE_EVENT(sdma_copy_batch_end,
	TP_PROTO(unsigned long count, int ret),

	TP_ARGS(count, ret),

	TP_STRUCT__entry(
		__field(unsigned long, count)
		__field(int, ret)
	),

	TP_fast_assign(
		__entry->count = count;
		__entry->ret = ret;
	),

	TP_printk("count=%#lx ret=%d", __entry->count, __entry->ret)
);

DECLARE_EVENT_CLASS(sdma_pin_pages_tp,
	TP_PROTO(struct pin_pages_data *data),

	TP_ARGS(data),

	TP_STRUCT__entry(
		__field(unsigned long, start)
		__field(unsigned long, len)
	),

	TP_fast_assign(
		__entry->start = data->start;
		__entry->len = data->len;
	),

	TP_printk("start=%#lx len=%#lx", __entry->start, __entry->len)
);

DEFINE_EVENT(sdma_pin_pages_tp, sdma_pin_pages_start,
	     TP_PROTO(struct pin_pages_data *data),
	     TP_ARGS(data));
DEFINE_EVENT(sdma_pin_pages_tp, sdma_unpin_pages_start,
	     TP_PROTO(struct pin_pages_data *data),
	     TP_ARGS(data));
DEFINE_EVENT(sdma_pin_pages_tp, sdma_unpin_pages_end,
	     TP_PROTO(struct pin_pages_data *data),
	     TP_ARGS(data));

TRACE_EVENT(sdma_pin_pages_end,
	TP_PROTO(struct pin_pages_data *data, int ret),

	TP_ARGS(data, ret),

	TP_STRUCT__entry(
		__field(unsigned long, start)
		__field(unsigned long, len)
		__field(int, ret)
	),

	TP_fast_assign(
		__entry->start = data->start;
		__entry->len = data->len;
		__entry->ret = ret;
	),

	TP_printk("start=%#lx len=%#lx ret=%d", __entry->start, __entry->len, __entry->ret)
);

TRACE_EVENT(sdma_submit_task,
	TP_PROTO(struct sdma_channel *pchan, unsigned long dst, unsigned long src,
		unsigned long len, int pasid),

	TP_ARGS(pchan, dst, src, len, pasid),

	TP_STRUCT__entry(
		__field(u16, idx)
		__field(u16, sq_tail)
		__field(int, pasid)
		__field(unsigned long, dst)
		__field(unsigned long, src)
		__field(unsigned long, len)
	),

	TP_fast_assign(
		__entry->idx = pchan->idx;
		__entry->sq_tail = pchan->sq_tail;
		__entry->pasid = pasid;
		__entry->dst = dst;
		__entry->src = src;
		__entry->len = len;
	),

	TP_printk("ch_idx=%#x sq_tail=%#x pasid=%d dst=%#lx src=%#lx len=%#lx",
			__entry->idx, __entry->sq_tail, __entry->pasid, __entry->dst,
			__entry->src, __entry->len)
);

#endif /* _TRACE_SDMA_H */

/* This part must be outside protection */
#include <trace/define_trace.h>
